using System;
using System.Collections.Generic;
using System.Text;
using DataTools;
using DataTools.PagingUtils;
using ObjectLayer;

namespace AccessLayer
{
	public class dim_costs_revenuesDAO
{
		public static List<dim_costs_revenuesBO> GetAll()
		{
			return CBO.FillCollection<dim_costs_revenuesBO>(DataProvider.getInstance().getAll(TableName.dim_costs_revenues, PagingHelper.CreateOrder(new OrderObject(dim_costs_revenuesTable.code, SortOrder.Desc))));
		}
		static object _Clock = new object();
		public static List<dim_costs_revenuesBO> GetAllC()
		{
            ConnInfo.Db = "VNPT_Bsc";
			List<dim_costs_revenuesBO> list = new List<dim_costs_revenuesBO>();
			if(DataCache.GetCache(CacheName.dim_costs_revenues) == null)
			{
				lock (_Clock)
				{
					if (DataCache.GetCache(CacheName.dim_costs_revenues) != null)
					{
						list = (List<dim_costs_revenuesBO>)DataCache.GetCache(CacheName.dim_costs_revenues);
					}
					else
					{
			list = CBO.FillCollection<dim_costs_revenuesBO>(DataProvider.getInstance().getAll(TableName.dim_costs_revenues, PagingHelper.CreateOrder(new OrderObject(dim_costs_revenuesTable.code, SortOrder.Desc))));
						DataCache.SetCache(CacheName.dim_costs_revenues, list);
					}
				}
			}
			else
			{
					list = (List<dim_costs_revenuesBO>)DataCache.GetCache(CacheName.dim_costs_revenues);
			}
		return list;
		}
		public static int InsertUpdateDelete(dim_costs_revenuesBO dim_costs_revenues, ProviderAction action)
		{
            ConnInfo.Db = "VNPT_Bsc";
			int rs = DataProvider.getInstance().InsertUpdateDelete(action, StoreProcedureName.InsertUpdateDelete_dim_costs_revenues, "@" + dim_costs_revenuesTable.code, dim_costs_revenues.code,dim_costs_revenues.name,dim_costs_revenues.unit_code,dim_costs_revenues.code2,dim_costs_revenues.code3,dim_costs_revenues.code4,dim_costs_revenues.code5,dim_costs_revenues.parent_code,dim_costs_revenues.note,dim_costs_revenues.slug, DataTools.ConvertType.ToInt(action));
			if (rs != -1)
			{
				DataCache.RemoveCache(CacheName.dim_costs_revenues);
			}
			return rs;
		}
		
	}
}